package com.midou.administration.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.midou.administration.entity.RoleFunction;
import com.midou.administration.mapper.RoleFunctionMapper;
import com.midou.administration.service.RoleFunctionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author MrChen
 * @since 2021-03-24
 */
@Service
public class RoleFunctionServiceImpl implements RoleFunctionService {
    @Resource
    private RoleFunctionMapper roleFunctionMapper;

    public List<RoleFunction> queryRolePermissions(Integer rid){
        QueryWrapper qw = new QueryWrapper();
        qw.eq("rf_role_id",rid);
        return roleFunctionMapper.selectList(qw);
    }
    public Integer addRoleFunction(RoleFunction rf){
        return roleFunctionMapper.insert(rf);
    }

    @Override
    public Integer delRoleFunction(RoleFunction rf) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("rf_role_id",rf.getRfRoleId());
        qw.eq("rf_function_id",rf.getRfFunctionId());
        return roleFunctionMapper.delete(qw);
    }

}
